﻿@{
    ViewBag.Title = "Category";
}
<h1>
    无限级下拉列表框</h1>
<script type="text/javascript">
    function areaOnSelect(obj) {
        var res = '';
        $.ajax({ url: '@Url.Action("GetSubTree")',
            type: 'GET',
            data: { parentId: obj.value },
            success: function (msg) {
                $(obj).nextAll().remove();
                res = "<select name='Sub' onchange='areaOnSelect(this)'>";
                res += "<option value=''>请选择</option>";
                $.each(msg, function (i, item) {
                    res += "<option value='" + item["ID"] + "'>" + item["Name"] + "</option>";
                });
                res += "</select>";
                if ($(res).find("option").size() > 1)
                    $(obj).after(res);
            }
        });
    }
</script>
@*@Html.DropDownList("Parent", ViewData["Parent"] as SelectList, new { onchange = "areaOnSelect(this)" })
*@
@Html.Raw(ViewData["edit"].ToString())
